﻿import base.bridgeAs2As3.BridgeFromToAs3;
import pw.archipelag.loaderGame.configVars.Net;
import pw.archipelag.loaderGame.configVars.MD5;

class pw.archipelag.loaderGame.configVars.ConfigVarsFromToAs3 extends BridgeFromToAs3 {
	
	private var net: Net;
	private var md5: MD5;
	
	function ConfigVarsFromToAs3() {
		this.net = new Net();
		this.md5 = new MD5();
	}
	
	public function configVars(args: Array) {
		var idSession: String = args[0];
		var scorePoints: Number = args[1];
		var scorePercent: Number = args[2];
		var path: String = (args[3]) ? String(args[3]) : "http://tester.archipelag.webstruments.pl/CommunicationService.svc/";
		var hashScoreUrl: String = this.md5.hash(String(idSession) + String(scorePoints) + String(scorePercent));//("podjazd" + String(idSession) + "dynamo" + String(scorePoints) + "archipelag" + String(scorePercent));
		var arrParams: Array = [/*["scorePercent", scorePercent], ["scorePoints", scorePoints], */["hash", hashScoreUrl]];
		var arrApplyFunction = new Array(2);
		arrApplyFunction[0] = function(isLoaded: Boolean, nodeScores: String) {
			this.call('backConfigVars', [isLoaded, String(nodeScores)]);
		}
		arrApplyFunction[1] = this;
		this.net.pobierzDaneZSerweraWKontekscieLokalnym(path + "saveresult/" + idSession + "/" + scorePoints + "/" + scorePercent, arrParams, arrApplyFunction, 60000, false);
	}
	
}